﻿using DMSkin.Core.MVVM;
using LiteDB;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;

namespace CloudMusic.Model
{
    public class MusicModel : ViewModelBase
    {
        private string index;

        /// <summary>
        /// 序号
        /// </summary>
        public string Index
        {
            get { return index; }
            set { index = value; OnPropertyChanged("Index");}
        }
        /// <summary>
        /// 所在歌单的品质 1-普通/2-精品歌单/3-本地歌单/4-每日推荐
        /// </summary>
        private int highQuality = 1;
        public int HighQuality
        {
            get { return highQuality; }
            set { highQuality = value; OnPropertyChanged("HighQuality"); }
        }
        private string url;
        /// <summary>
        /// 歌曲路径
        /// </summary>
        public string Url
        {
            get { return url; }
            set { url = value; OnPropertyChanged("Url"); }
        }

        private string name;

        /// <summary>
        /// 标题
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; OnPropertyChanged("Name");}
        }
        private string subtitle;
        /// <summary>
        /// 副标题
        /// </summary>
        public string Subtitle
        {
            get { return subtitle; }
            set { subtitle = value; OnPropertyChanged("Subtitle"); }
        }

        private double size;

        /// <summary>
        /// 体积
        /// </summary>
        public double Size
        {
            get { return size; }
            set { size = value;OnPropertyChanged("Size");}
        }

        /// <summary>
        /// 体积-MB
        /// </summary>
        public string SizeStr
        {
            get
            {
                return HumanReadableFilesize(size);
            }
        }

        private String HumanReadableFilesize(double size)
        {
            String[] units = new String[] { "B", "KB", "MB", "GB", "TB", "PB" };
            double mod = 1024.0;
            int i = 0;
            while (size >= mod)
            {
                size /= mod;
                i++;
            }
            return Math.Round(size, 2) + units[i];
        }

        private string album;

        /// <summary>
        /// 专辑
        /// </summary>
        public string Album
        {
            get { return album; }
            set { album = value; OnPropertyChanged("Album");}
        }

        private string artist;

        /// <summary>
        /// 作者
        /// </summary>
        public string Artist
        {
            get { return artist; }
            set { artist = value;  OnPropertyChanged("Artist");}
        }

        private string timeStr;

        /// <summary>
        /// 时长
        /// </summary>
        public string TimeStr
        {
            get { return timeStr; }
            set {  timeStr = value; OnPropertyChanged("TimeStr");}
        }

        public string FileName { get; internal set; }

        private bool download;

        /// <summary>
        /// 下载状态
        /// </summary>
        public bool DownLoad
        {
            get { return download; }
            set {  download = value; OnPropertyChanged("DownLoad");}
        }

        private string picUrl;
        /// <summary>
        /// 封面
        /// </summary>
        public string PicUrl
        {
            get { return picUrl; }
            set { picUrl = value;OnPropertyChanged("PicUrl");}

        }
        private string _blurPicUrl;
        /// <summary>
        /// 模糊背景图
        /// </summary>
        public string blurPicUrl
        {
            get { return _blurPicUrl; }
            set { _blurPicUrl = value; OnPropertyChanged("blurPicUrl"); }
        }
        [BsonId]
        public Guid Guid { get; set; }
        private Int64 id;
        /// <summary>
        /// 歌曲标志
        /// </summary>
        public Int64 Id
        {
            get { return id; }
            set { id = value; OnPropertyChanged("Id");}
        }

        private long songId;
        /// <summary>
        /// 歌单ID
        /// </summary>
        public long SongId
        {
            get { return songId; }
            set { songId = value; OnPropertyChanged("SongId");}
        }
        public int type;
        /// <summary>
        /// type : 0 本地音乐， 1 网页音乐
        /// </summary>
        public int Type
        {
            get { return type; }
            set { type = value; OnPropertyChanged("Type");}
        }
        private Int64 singerId;
        /// <summary>
        /// 演唱者id
        /// </summary>
        public Int64 SingerId
        {
            get { return singerId; }
            set { singerId = value;OnPropertyChanged("SingerId");}
        }

        private Int64 albumId;
        /// <summary>
        /// 专辑id
        /// </summary>
        public Int64 AlbumId
        {
            get { return albumId; }
            set { albumId = value; OnPropertyChanged("AlbumId");}
        }

        private string vipVis = "Collapsed";   
        /// <summary>
        /// 是否为vip歌曲
        /// </summary>
        public string VIPVis
        {
            get { return vipVis; }
            set { vipVis = value; OnPropertyChanged("VIPVis"); }
        }
        private string stVis = "Collapsed";
        /// <summary>
        /// 是否为试听歌曲
        /// </summary>
        public string STVis
        {
            get { return stVis; }
            set { stVis = value; OnPropertyChanged("STVis"); }
        }
        private string sqVis = "Collapsed";
        /// <summary>
        /// 是否为高品质歌曲
        /// </summary>
        public string SQVis
        {
            get { return sqVis; }
            set { sqVis = value; OnPropertyChanged("SQVis"); }
        }
        private string mvVis = "Collapsed";
        /// <summary>
        ///该歌曲是否有MV
        /// </summary>
        public string MVVis
        {
            get { return mvVis; }
            set { mvVis = value; OnPropertyChanged("MVVis"); }
        }
        private string coverTitle;
        /// <summary>
        /// 鼠标上移显示完整标题
        /// </summary>
        public string CoverTitle
        {
            get { return coverTitle; }
            set { coverTitle = value; OnPropertyChanged("CoverTitle"); }
        }
        private bool canPlay;
        /// <summary>
        /// 是否可以播放
        /// </summary>
        public bool CanPlay
        {
            get { return canPlay; }
            set { canPlay = value; OnPropertyChanged("CanPlay"); }
        }
        private string source;
        /// <summary>
        /// 歌曲来源
        /// </summary>
        public string Source
        {
            get { return source; }
            set { source = value; OnPropertyChanged("Source"); }
        }
        /// <summary>
        /// 歌曲热度
        /// </summary>
        public string pop;
        public string Pop
        {
            get { return pop; }
            set { pop = value;OnPropertyChanged("Pop"); }
        }

        /// <summary>
        /// 歌曲播放码率
        /// </summary>
        private List<ChargeInfo> chargeInfoList;
        public List<ChargeInfo> ChargeInfoList
        {
            get { return chargeInfoList; }
            set { chargeInfoList = value;OnPropertyChanged("ChargeInfoList"); }
        }
        /// <summary>
        /// 副标题是否显示
        /// </summary>
        private Visibility subtitleVis;
        public Visibility SubtitleVis
        {
            get { return subtitleVis; }
            set { subtitleVis = value; OnPropertyChanged("SubtitleVis"); }
        }
        /// <summary>
        /// 是否正在播放
        /// </summary>
        private bool playing;
        public bool Playing
        {
            get { return playing; }
            set { playing = value;OnPropertyChanged("Playing"); }
        }

        private long mvid;
        public long mvId
        {
            get { return mvid; }
            set { mvid = value;OnPropertyChanged("mvId"); }
        }

        private int like;
        public int Like
        {
            get { return like; }
            set { like = value; OnPropertyChanged("Like"); }
        }
    }
    //播放数据存放
    public class PlayModel : ViewModelBase
    {
        private string index;

        /// <summary>
        /// 序号
        /// </summary>
        public string Index
        {
            get { return index; }
            set { index = value; OnPropertyChanged("Index"); }
        }
        /// <summary>
        /// 所在歌单的品质 1-普通/2-精品歌单/3-本地歌单/4-每日推荐
        /// </summary>
        private int highQuality = 1;
        public int  HighQuality
        {
            get { return highQuality; }
            set { highQuality = value; OnPropertyChanged("HighQuality"); }
        }
        private string url;
        /// <summary>
        /// 歌曲路径
        /// </summary>
        public string Url
        {
            get { return url; }
            set { url = value; OnPropertyChanged("Url"); }
        }

        private string name;

        /// <summary>
        /// 标题
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; OnPropertyChanged("Name"); }
        }

        private string subtitle;
        /// <summary>
        /// 副标题
        /// </summary>
        public string Subtitle
        {
            get { return subtitle; }
            set { subtitle = value;OnPropertyChanged("Subtitle"); }
        }
        private double size;

        /// <summary>
        /// 体积
        /// </summary>
        public double Size
        {
            get { return size; }
            set { size = value; OnPropertyChanged("Size"); }
        }

        /// <summary>
        /// 体积-MB
        /// </summary>
        public string SizeStr
        {
            get
            {
                return HumanReadableFilesize(size);
            }
        }

        private String HumanReadableFilesize(double size)
        {
            String[] units = new String[] { "B", "KB", "MB", "GB", "TB", "PB" };
            double mod = 1024.0;
            int i = 0;
            while (size >= mod)
            {
                size /= mod;
                i++;
            }
            return Math.Round(size, 2) + units[i];
        }

        private string album;

        /// <summary>
        /// 专辑
        /// </summary>
        public string Album
        {
            get { return album; }
            set { album = value; OnPropertyChanged("Album"); }
        }

        private string artist;

        /// <summary>
        /// 作者
        /// </summary>
        public string Artist
        {
            get { return artist; }
            set { artist = value; OnPropertyChanged("Artist"); }
        }

        private string timeStr;

        /// <summary>
        /// 时长
        /// </summary>
        public string TimeStr
        {
            get { return timeStr; }
            set { timeStr = value; OnPropertyChanged("TimeStr"); }
        }
        /// <summary>
        /// 全路径
        /// </summary>
        public string FileName { get; internal set; }

        private bool download;

        /// <summary>
        /// 下载状态
        /// </summary>
        public bool DownLoad
        {
            get { return download; }
            set { download = value; OnPropertyChanged("DownLoad"); }
        }

        private string picUrl;
        /// <summary>
        /// 封面
        /// </summary>
        public string PicUrl
        {
            get { return picUrl; }
            set { picUrl = value; OnPropertyChanged("PicUrl"); }

        }
        private string _blurPicUrl;
        /// <summary>
        /// 模糊背景图
        /// </summary>
        public string blurPicUrl
        {
            get { return _blurPicUrl; }
            set { _blurPicUrl = value; OnPropertyChanged("blurPicUrl"); }
        }
        private Int64 id;
        /// <summary>
        /// 歌曲标志
        /// </summary>
        public Int64 Id
        {
            get { return id; }
            set { id = value; OnPropertyChanged("Id"); }
        }

        private long songId;
        /// <summary>
        /// 歌单ID
        /// </summary>
        public long SongId
        {
            get { return songId; }
            set { songId = value; OnPropertyChanged("SongId"); }
        }
        public int type;
        /// <summary>
        /// type : 0 本地音乐， 1 网页音乐
        /// </summary>
        public int Type
        {
            get { return type; }
            set { type = value; OnPropertyChanged("Type"); }
        }
        private Int64 singerId;
        /// <summary>
        /// 演唱者id
        /// </summary>
        public Int64 SingerId
        {
            get { return singerId; }
            set { singerId = value; OnPropertyChanged("SingerId"); }
        }

        private Int64 albumId;
        /// <summary>
        /// 专辑id
        /// </summary>
        public Int64 AlbumId
        {
            get { return albumId; }
            set { albumId = value; OnPropertyChanged("AlbumId"); }
        }

        private string vipVis = "Collapsed";
        /// <summary>
        /// 是否为vip歌曲
        /// </summary>
        public string VIPVis
        {
            get { return vipVis; }
            set { vipVis = value; OnPropertyChanged("VIPVis"); }
        }
        private string stVis = "Collapsed";
        /// <summary>
        /// 是否为试听歌曲
        /// </summary>
        public string STVis
        {
            get { return stVis; }
            set { stVis = value; OnPropertyChanged("STVis"); }
        }
        private string sqVis = "Collapsed";
        /// <summary>
        /// 是否为高品质歌曲
        /// </summary>
        public string SQVis
        {
            get { return sqVis; }
            set { sqVis = value; OnPropertyChanged("SQVis"); }
        }
        private string mvVis = "Collapsed";
        /// <summary>
        ///该歌曲是否有MV
        /// </summary>
        public string MVVis
        {
            get { return mvVis; }
            set { mvVis = value; OnPropertyChanged("MVVis"); }
        }
        private string coverTitle;
        /// <summary>
        /// 鼠标上移显示完整标题
        /// </summary>
        public string CoverTitle
        {
            get { return coverTitle; }
            set { coverTitle = value; OnPropertyChanged("CoverTitle"); }
        }

        private bool canPlay;
        /// <summary>
        /// 是否可以播放
        /// </summary>
        public bool CanPlay
        {
            get { return canPlay; }
            set { canPlay = value;OnPropertyChanged("CanPlay"); }
        }
        private string source;
        /// <summary>
        /// 歌曲来源
        /// </summary>
        public string Source
        {
            get { return source; }
            set { source = value; OnPropertyChanged("Source"); }
        }
        /// <summary>
        /// 歌曲热度
        /// </summary>
        public string pop;
        public string Pop
        {
            get { return pop; }
            set { pop = value; OnPropertyChanged("Pop"); }
        }

        /// <summary>
        /// 歌曲播放码率
        /// </summary>
        private List<ChargeInfo> chargeInfoList;
        public List<ChargeInfo> ChargeInfoList
        {
            get { return chargeInfoList; }
            set { chargeInfoList = value; OnPropertyChanged("ChargeInfoList"); }
        }

        /// <summary>
        /// 副标题是否显示
        /// </summary>
        private Visibility subtitleVis;
        public Visibility SubtitleVis
        {
            get { return subtitleVis; }
            set { subtitleVis = value; OnPropertyChanged("SubtitleVis"); }
        }
        /// <summary>
        /// 是否正在播放
        /// </summary>
        private bool playing;
        public bool Playing
        {
            get { return playing; }
            set { playing = value; OnPropertyChanged("Playing"); }
        }
        private long mvid;
        public long mvId
        {
            get { return mvid; }
            set { mvid = value; OnPropertyChanged("mvId"); }
        }
        private int like;
        public int Like
        {
            get { return like; }
            set { like = value; OnPropertyChanged("Like"); }
        }
    }
    public class ChargeInfo: ViewModelBase
    {
        /// <summary>
        /// 码率
        /// </summary>
        public string rate;
        public string Rate
        {
            get { return rate; }
            set { rate = value; OnPropertyChanged("Rate"); }
        }
        /// <summary>
        /// 切换地址
        /// </summary>
        public string chargeUrl;
        public string ChargeUrl
        {
            get { return chargeUrl; }
            set { chargeUrl = value; OnPropertyChanged("ChargeUrl"); }
        }
        /// <summary>
        /// 切换信息
        /// </summary>
        public string chargeMessage;
        public string ChargeMessage
        {
            get { return chargeMessage; }
            set { chargeMessage = value; OnPropertyChanged("ChargeMessage"); }
        }
        /// <summary>
        /// 切换类型
        /// </summary>
        public string chargeType;
        public string ChargeType
        {
            get { return chargeType; }
            set { chargeType = value; OnPropertyChanged("ChargeType"); }
        }

    }
    public class History
    {
        [BsonId]
        public Guid Id { get; set; }
        public string Keyword { get; set; }
        public DateTime CreateTime { get; set; }
    }
}
